﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.peddler {
    import Classes.*;

    public class PeddlerModel {

        public static const HASPLACED:String = "placedIt";
        public static const STATE_WORKING:String = "busy";
        public static const STATE_REST:String = "sleep";
        public static const STATE_FREE:String = "free";

        protected var m_allowed:Boolean;
        protected var m_name:String;
        protected var m_ownerId:String;
        protected var m_peddlerId:String;
        protected var m_pdlr_state:String = "";
        protected var m_plantTime:Number;
        protected var m_hostId:String = "";
        public var count:int = 1;

        public function PeddlerModel(_arg1:Boolean=false, _arg2:String="", _arg3:String="", _arg4:String="", _arg5:String="", _arg6:Number=0, _arg7:String=""){
            this.m_allowed = _arg1;
            this.m_name = _arg2;
            this.m_ownerId = _arg3;
            this.m_peddlerId = _arg4;
            this.m_pdlr_state = _arg5;
            this.m_plantTime = _arg6;
            this.m_hostId = _arg7;
        }
        public function set allowed(_arg1:Boolean):void{
            this.m_allowed = _arg1;
        }
        public function get allowed():Boolean{
            return (this.m_allowed);
        }
        public function set ownerId(_arg1:String):void{
            this.m_ownerId = _arg1;
        }
        public function get ownerId():String{
            return (this.m_ownerId);
        }
        public function set hostId(_arg1:String):void{
            this.m_hostId = _arg1;
        }
        public function get hostId():String{
            return (this.m_hostId);
        }
        public function get peddlerId():String{
            return (this.m_peddlerId);
        }
        public function get name():String{
            return (this.m_name);
        }
        public function get status():String{
            var _local1 = "icon";
            switch (this.m_pdlr_state){
                case HarvestableResource.STATE_PLOWED:
                    _local1 = STATE_FREE;
                    break;
                case HarvestableResource.STATE_GROWN:
                case HarvestableResource.STATE_PLANTED:
                case HarvestableResource.STATE_GROWN:
                    _local1 = STATE_WORKING;
                    break;
                case "sleep":
                    _local1 = STATE_REST;
                    break;
            };
            return (_local1);
        }
        public function set status(_arg1:String):void{
            this.m_pdlr_state = _arg1;
        }
        public function get counting_time():Number{
            return (this.m_plantTime);
        }
        public function set counting_time(_arg1:Number):void{
            this.m_plantTime = _arg1;
        }
        public function get item():Item{
            return (Global.gameSettings.getItemByName(this.m_name));
        }
        public function get harvest():Boolean{
            return ((this.m_pdlr_state == HarvestableResource.STATE_GROWN));
        }
        public function get licence():Boolean{
            return (this.m_allowed);
        }
        public function get maxIncome():int{
            var _local4:Object;
            var _local1:Array = this.item.phases.sortOn("ord");
            var _local2:Number = 0;
            var _local3:uint;
            while (_local3 < _local1.length) {
                _local4 = _local1[_local3];
                _local2 = (_local2 + (((_local4.rate * Global.gameSettings.inGameDaySeconds) * _local4.duration) / 60));
                _local3++;
            };
            return (int(_local2));
        }

    }
}//package Modules.peddler 
